from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.forms import UserChangeForm
from import_export.admin import ExportActionModelAdmin

from .models import MyUser


# Register your models here.

@admin.register(MyUser)
class MyUserAdmin(UserAdmin):
    list_display = ('id', 'username', 'email', 'nickname', 'is_staff', 'date_joined','is_superuser')
    list_filter = ('is_staff', 'is_active', 'date_joined')
    search_fields = ('username', 'email', 'nickname')
    ordering = ('id', 'username', 'email', 'is_staff', 'is_active', 'date_joined')
    readonly_fields = ('id', 'date_joined')
    form = UserChangeForm
    fieldsets = (
        (None, {'fields': ('username', 'email', 'nickname')}),
        ('权限', {'fields': ('is_staff', 'is_active', 'is_superuser', 'groups')}),
        ('创建时间', {'fields': ('date_joined',)}),
    )
    add_fieldsets = (
        (None, {'fields': ('username', 'email', 'nickname', 'password1', 'password2')}),
        ('Permissions', {'fields': ('is_staff', 'is_active','is_superuser', 'groups')}),
    )

